package com.guoheng.hazard.sys.controller.hazard;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.hazard.MonitorSensorInsertDTO;
import com.guoheng.hazard.sys.model.dto.hazard.MonitorSensorUpdateDTO;
import com.guoheng.hazard.sys.service.hazard.MonitorSensorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 类功能描述:　MonitorSensorController
 *
 * @author Eternal
 * @date 2019-11-20 17:54
 */
@RestController
@Validated
@Api(value = "传感器信息")
public class MonitorSensorController {

    @Resource
    MonitorSensorService monitorSensorService;

    @ApiOperation(value = "查询传感器列表信息")
    @GetMapping(value = "data/major/hazard/sensors")
    public Result getMonitorSensors(Long entprId, String entprName, String sensorNo, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return monitorSensorService.getMonitorSensors(entprId, entprName, sensorNo, pageNum, pageSize);
    }

    @ApiOperation(value = "修改传感器信息")
    @PutMapping(value = "data/major/hazard/sensor")
    public Result updateMonitorSensor(@RequestBody @Valid MonitorSensorUpdateDTO monitorSensorUpdateDTO) {
        return monitorSensorService.updateMonitorSensor(monitorSensorUpdateDTO);
    }

    @ApiOperation(value = "新增传感器信息")
    @PostMapping(value = "data/major/hazard/sensor")
    public Result insertMonitorSensor(@RequestBody @Valid MonitorSensorInsertDTO monitorSensorInsertDTO) {
        return monitorSensorService.insertMonitorSensor(monitorSensorInsertDTO);
    }

    @ApiOperation(value = "删除传感器信息")
    @DeleteMapping(value = "data/major/hazard/sensor/{id}")
    public Result deleteMonitorSensor(@PathVariable @NotNull Long id) {
        return monitorSensorService.deleteMonitorSensor(id);
    }

    @ApiOperation(value = "查询传感器详情信息")
    @GetMapping(value = "data/major/hazard/sensor/{id}")
    public Result getMonitorSensor(@PathVariable @NotNull Long id) {
        return monitorSensorService.getMonitorSensor(id);
    }

    @ApiOperation(value = "传感器数据列表")
    @GetMapping(value = "data/major/hazard/sensor/data")
    public Result sensorData(Long entprId, String sensorNo, Long beginTime, Long endTime, @RequestParam Integer pageNum, @RequestParam Integer pageSize) {
        return monitorSensorService.sensorData(entprId, sensorNo, beginTime, endTime, pageNum, pageSize);
    }

}